<script setup lang="ts" name="login">
import '@/assets/css/animation.css'
import useLoginIndex from '@/components/login/hooks/loginIndex'
const {
  MsgUps,
  isPops,
  childRef,
  closeBtn,
  componentsControl,
  changeForms,
  registForm,
  loginForm
} = useLoginIndex()
</script>

<template>
  <div id="main">
    <div class="back">
      <div class="content">
        <img class="logo" src="@/assets/logo.svg" alt="" />
        <main>
          <button v-show="closeBtn" @click="changeForms" class="close">❌</button>
          <component ref="childRef" :is="componentsControl" />
        </main>
      </div>
      <div class="btns">
        <button @click="registForm" class="regist">注册</button>
        <button @click="loginForm" class="login">登录</button>
      </div>
    </div>
  </div>
  <Transition name="slide-fade">
    <component :is="MsgUps" v-show="isPops"></component>
  </Transition>
</template>

<style scoped lang="less">
#main {
  width: 100vw;
  height: 100vh;
  background-color: var(--color1);
  background-repeat: no-repeat;
  background-size: cover;
  background-position: center top;
}

main {
  position: absolute;
  top: 50%;
  left: 50%;
  min-height: 240px;
  max-height: 340px;
  width: 350px;
  translate: 0 -50%;
  background-color: var(--color2);
  border-radius: 6px;
  overflow: hidden;
}

.back {
  position: relative;
  left: 50%;
  top: 40%;
  translate: -50% -50%;
  width: 900px;
  height: 600px;
  border-radius: 6px;
  background-image: url('@/assets/login-access-imgs/card.png');
  background-size: cover;

  .content {
    backdrop-filter: blur(5px);
    width: 900px;
    height: 600px;
    border-radius: 6px;
    .logo {
      position: absolute;
      top: 50%;
      left: 50%;
      translate: -140% -50%;
      width: 240px;
      height: 240px;
    }

    .close {
      cursor: pointer;
      position: absolute;
      top: 0;
      right: 0;
      height: 36px;
      width: 36px;
      font-size: 16px;
      border-radius: 0 6px 0 0;
      background-color: var(--color2);
    }
    .close:hover {
      background-color: var(--color1);
    }
  }
  .btns {
    position: absolute;
    top: 86%;
    left: 50%;
    translate: -50% 0%;
  }
  .login,
  .regist {
    border-radius: var(--radius);
    height: 50px;
    width: 160px;
    background-color: var(--color2);
    margin: 0 30px;
  }
  .login:hover,
  .regist:hover {
    cursor: pointer;
    background-color: var(--color1);
    color: var(--color3);
  }
  .login:active,
  .regist:active {
    background-color: var(--color1);
    color: var(--color3);
  }
}

button {
  border: none;
  color: var(--color3);
  font-size: 20px;
}
</style>
